package com.go.ssh.point.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * 商品表
 * 
 */
@Entity
@Table(name = "tb_goods")
public class GoodsModel implements java.io.Serializable {

	private static final long serialVersionUID = -8270666768071879501L;

	/** 主键 */
	private int id;

	/** 商品名称 */
	private String name;

	/** 商品简介 */
	private String description;

	/** 原需积分 */
	private int originalPoint;

	/** 现需积分 */
	private int nowPoint;

	/** 是否发布，只有发布的在前台显示 */
	private boolean published;

	/** 是否删除，商品不会被物理删除的 */
	private boolean deleted;

	/** 版本 */
	private int version;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq")
	@SequenceGenerator(name = "seq", sequenceName = "tb_goods_id_seq")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 100)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description", nullable = false, length = 100)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "original_point", nullable = false, length = 10)
	public int getOriginalPoint() {
		return originalPoint;
	}

	public void setOriginalPoint(int originalPoint) {
		this.originalPoint = originalPoint;
	}

	@Column(name = "now_point", nullable = false, length = 10)
	public int getNowPoint() {
		return nowPoint;
	}

	public void setNowPoint(int nowPoint) {
		this.nowPoint = nowPoint;
	}

	@Column(name = "published", nullable = false)
	public boolean isPublished() {
		return published;
	}

	public void setPublished(boolean published) {
		this.published = published;
	}

	@Column(name = "is_delete", nullable = false)
	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	@Version
	@Column(name = "version", nullable = false, length = 10)
	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		GoodsModel other = (GoodsModel) obj;
		if (id != other.id)
			return false;
		return true;
	}

}
